import React, { useRef, useState, useEffect } from 'react';
import { connect } from 'umi';
import TableDataBlock from '@/components/TableDataBlock';
import { Button, Modal, Space, Form, Row, Col } from 'antd';
import { notification } from 'antd';
import FormCondition from '@/components/FormCondition';
const SelectPromoterGroup = (props) => {
    const {
        visible = false,
        onClose,
        loading,
        type = 'checkBox',
        onChange,
        dispatch
    } = props;
    const { show = false, detail = {} } = visible;
    const { } = detail
    const [form] = Form.useForm();
    const formItems = [
        {
            label: '分组',
            name: type === 'checkBox' ? 'groupIds' : 'groupId',
            type: 'promoterGroup',
            mode: type === 'checkBox' ? 'multiple' : null
        },
    ];

    const handleUpAudit = () => {
        form.validateFields().then((values) => {
            onChange(values)
            onClose()
        });

    };

    const modalProps = {
        title: '设置分组',
        width: 900,
        visible: typeof visible === 'boolean' ? visible : show,
        maskClosable: true,
        destroyOnClose: true,
        zIndex: 1001,
        confirmLoading: loading,
        footer: <Space>
            <Button onClick={() => onClose()}>取消</Button>
            <Button type='primary' onClick={() => handleUpAudit()}>确定</Button>
        </Space>
    };

    return (
        <Modal {...modalProps} onCancel={onClose} onOk={handleUpAudit}>
            <FormCondition form={form} formItems={formItems} initialValues={detail}></FormCondition>
        </Modal>
    );
};

export default connect(({ selectionWindow, loading }) => ({
    list: selectionWindow.promoterGroupList,
    loading: loading.models.selectionWindow,
}))(SelectPromoterGroup);
